#version 430 core

layout (local_size_x = 300) in;
struct VertexProp{
    float prop[7];
};

layout (binding = 0) coherent buffer block01 {
    VertexProp vertices[];
}bufferData;

uniform float speedAdded;
void main(void)
{
    float radius = 0.0005f + speedAdded;
    radius = radius + ((0.0005f +speedAdded) * ( float(gl_WorkGroupID.y) / float(gl_NumWorkGroups.y) * 0.5f) * (float(gl_NumWorkGroups.y) - float(gl_WorkGroupID.y)/2.0f));
    uint vertexId = gl_WorkGroupID.z * gl_NumWorkGroups.y * gl_NumWorkGroups.x \
                    + gl_WorkGroupID.y * gl_NumWorkGroups.x \
                    + gl_WorkGroupID.x \
                    + gl_LocalInvocationID.z * gl_WorkGroupSize.y * gl_WorkGroupSize.x \
                    + gl_LocalInvocationID.y * gl_WorkGroupSize.x \
                    + gl_LocalInvocationID.x;

    float hAngle = (float(gl_WorkGroupID.x) * (360.0f / float(gl_NumWorkGroups.x))) \
                     + ((1.0f / float(gl_WorkGroupSize.x)) * float(gl_LocalInvocationID.x));

    bufferData.vertices[vertexId].prop[0] = radius * cos(radians(hAngle));
    bufferData.vertices[vertexId].prop[1] = float(gl_WorkGroupID.y) * (0.00005f + speedAdded / 5.0f);
    bufferData.vertices[vertexId].prop[2] = radius * sin(radians(hAngle));

    bufferData.vertices[vertexId].prop[3] = 1.0f;
    bufferData.vertices[vertexId].prop[4] = (130.0f * (1.0f - (float(gl_WorkGroupID.y) / float(gl_NumWorkGroups.y)))) / 255.0f;
    bufferData.vertices[vertexId].prop[5] = 0.0f;

    bufferData.vertices[vertexId].prop[6] = (1.0f - (float(gl_WorkGroupID.y) / float(gl_NumWorkGroups.y))) * (1.0f/2.0f);
}
